package com.bawei.wyg.mycommerce.databinding.rec;

import androidx.databinding.BindingAdapter;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.List;

public class RecyclerAdapter {
    @BindingAdapter(value = {"datas"},requireAll = false)
    public static void LinearReclerView(RecyclerView recyclerView, List<Object> datas){
        BaseQuickAdapter adapter = (BaseQuickAdapter) recyclerView.getAdapter();
        if(adapter==null){
            LinearLayoutManager manager = new LinearLayoutManager(recyclerView.getContext());
            manager.setOrientation(LinearLayoutManager.VERTICAL);
             adapter = new TestRVAdapter();
            recyclerView.setLayoutManager(manager);
            recyclerView.setAdapter(adapter);
            adapter.setNewData(datas);
        }else{
            adapter.setNewData(datas);
        }

    }
}
